package geez.widget;

import com.google.gwt.event.dom.client.BlurHandler;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.FocusHandler;
import com.google.gwt.user.client.ui.TextArea;

import static geez.widget.Geez.withStyle;

public class GTextArea extends TextArea implements GChangable, GFocusable, GTextSetable {

    public GTextArea(String text) {
        text(text);
    }

    public GTextArea id(String id) {
        Geez.withNameAndId(this, id);
        return this;
    }

    public GTextArea css(String cssClass, String... optionalClasses) {
        withStyle(this, cssClass, optionalClasses);
        return this;
    }

    public GTextArea tabIndex(int index) {
        setTabIndex(index);
        return this;
    }

    public GTextArea text(String text) {
        setText(text);
        return this;
    }

    public GTextArea hide() {
        setVisible(false);
        return this;
    }

    public GTextArea show() {
        setVisible(true);
        return this;
    }

    public GTextArea add(ChangeHandler handler) {
        addChangeHandler(handler);
        return this;
    }

    public GTextArea add(FocusHandler handler) {
        addFocusHandler(handler);
        return this;
    }

    public GTextArea add(BlurHandler handler) {
        addBlurHandler(handler);
        return this;
    }

    public GTextArea enable() {
        setEnabled(true);
        return this;
    }

    public GTextArea disable() {
        setEnabled(false);
        return this;
    }

    public GTextArea focus() {
        setFocus(true);
        return this;
    }
}
